#include <iostream>

using namespace std;

const int N = 100010;
int n, m, l, r;
int a[N], s[N];

int pre1(int s[], int l, int r)
{
    return s[r] - s[l - 1];
}

int main()
{
    s[0] = 0, a[0] = 0;
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; ++i)
    {
        scanf("%d", a + i);
        s[i] = s[i - 1] + a[i];
    }
    for (int i = 0; i < m; ++i)
    {
        scanf("%d%d", &l, &r);
        printf("%d\n", pre1(s, l, r));
    }
    return 0;
}